package com.lyl.dangdang.controller;


import com.lyl.dangdang.pojo.Result;
import com.lyl.dangdang.pojo.dto.LoginDto;
import com.lyl.dangdang.pojo.dto.PayDateDto;
import com.lyl.dangdang.pojo.dto.RegisterCodeDto;
import com.lyl.dangdang.pojo.dto.RegisterDto;
import com.lyl.dangdang.service.IUserService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liyunlong
 * @since 2024-06-03
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private IUserService userService;


    @PostMapping("/login")
    public Result login(@RequestBody LoginDto loginDto) {
        return userService.login(loginDto);
    }
    @RequestMapping("/getCode")
    public void getCode(HttpServletResponse response) {
        userService.getCode(response);
    }

    @PostMapping("register")
    public Result register(@RequestBody RegisterDto registerDto){
        return  userService.register(registerDto);
    }

    @PostMapping("/getRegisterInfo/{id}")
    public Result getRegisterInfo(@PathVariable("id")Long id){
        return userService.getRegisterInfo(id);
    }
    @PostMapping("/verifyRegisterCode")
    public Result verifyRegisterCode(@RequestBody RegisterDto registerDto){
        return userService.verifyRegisterCode(registerDto);
    }
    @GetMapping("/getUserAddress")
    public Result getUserAddress(){
        return userService.getUserAddress();
    }
    @GetMapping("/getUserCartsBook")
    public Result getUserCartsBook(){
        return userService.getUserCartsBook();
    }

    @PostMapping("/payOrder")
    public Result payOrder(@RequestBody PayDateDto payDateDto){
        return   userService.payOrder(payDateDto);

    }

}
